package com.imonsoft.sqm.dao.basedata;

import com.imonsoft.common.httpModel.DataGrid;
import com.imonsoft.common.httpModel.Pager;
import com.imonsoft.sqm.pojo.basedata.IpicRule;
import com.imonsoft.sqm.pojo.basedata.IpicRuleExample;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@SuppressWarnings("deprecation")
@Repository("ipicRuleDAO")
public class IpicRuleDAOImpl extends SqlMapClientDaoSupport implements IpicRuleDAO {

    /**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public IpicRuleDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int countIpicRuleByExample(IpicRuleExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"tt_ipic_rule.ibatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int deleteIpicRuleByExample(IpicRuleExample example) {
		int rows = getSqlMapClientTemplate().delete(
				"tt_ipic_rule.ibatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int deleteIpicRuleByPrimaryKey(Long id) {
		IpicRule key = new IpicRule();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete(
				"tt_ipic_rule.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public Long insertIpicRule(IpicRule record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"tt_ipic_rule.ibatorgenerated_insert", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public Long insertIpicRuleSelective(IpicRule record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"tt_ipic_rule.ibatorgenerated_insertSelective", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	@SuppressWarnings("unchecked")
	public List<IpicRule> selectIpicRuleByExample(IpicRuleExample example) {
		List<IpicRule> list = getSqlMapClientTemplate().queryForList(
				"tt_ipic_rule.ibatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public IpicRule selectIpicRuleByPrimaryKey(Long id) {
		IpicRule key = new IpicRule();
		key.setId(id);
		IpicRule record = (IpicRule) getSqlMapClientTemplate().queryForObject(
				"tt_ipic_rule.ibatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int updateIpicRuleByExampleSelective(IpicRule record,
			IpicRuleExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"tt_ipic_rule.ibatorgenerated_updateByExampleSelective", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int updateIpicRuleByExample(IpicRule record, IpicRuleExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"tt_ipic_rule.ibatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int updateIpicRuleByPrimaryKeySelective(IpicRule record) {
		int rows = getSqlMapClientTemplate().update(
				"tt_ipic_rule.ibatorgenerated_updateByPrimaryKeySelective",
				record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	public int updateIpicRuleByPrimaryKey(IpicRule record) {
		int rows = getSqlMapClientTemplate().update(
				"tt_ipic_rule.ibatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table tt_ipic_rule
	 * @ibatorgenerated  Thu May 30 10:07:24 CST 2013
	 */
	private static class UpdateByExampleParms extends IpicRuleExample {
		private Object record;

		public UpdateByExampleParms(Object record, IpicRuleExample example) {
			super(example);
			this.record = record;
		}

		@SuppressWarnings("unused")
		public Object getRecord() {
			return record;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public DataGrid<IpicRule> getDataGrid(IpicRuleExample example, Pager pager) {
		if (example == null) {
			example = new IpicRuleExample();
		}
		int total = countIpicRuleByExample(example);
		List<IpicRule> rows = getSqlMapClientTemplate().queryForList("tt_ipic_rule.ibatorgenerated_selectByExample", example, pager.getSkipResults(), pager.getRows());
		DataGrid<IpicRule> dataGrid = new DataGrid<IpicRule>(total, rows);
		return dataGrid;
	}
}